<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
        <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
        <title>分类</title>
        <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
        <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
        <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>
        <style>
            .selectActive {
                background-color: #FADDCF !important;
                color: #EB7B3D;
            }
        </style>
    </head>
    <body >
        <div class="header" id="blank">
            <div v-back.tapmode class="back"></div>
            <span class="title">商品详情</span>
        </div>
        <div id="app" style="min-height:120%" v-cloak>
          <div style="padding-top:62px"><img :src="goods_info.pic" style="width:100%"></div>
            <div class="memberright-container"><span class="myright">{{member_type==5?'VIP':'店主'}}专享</span><span style="line-height:25px;padding-left:10px;font-size:14px">赚：{{member_type==5?goods_info.t5_gain_max:goods_info.t6_gain_max}}元</span></div>
            <div style="background:#ffffff">
            <div class="goods_info_container">
              <div class="share_info_container_div">
                <div class="share_info_container_div_left">
                  <span class="real_price">券后￥<span style="font-size:24px">{{goods_info.price}}</span></span>
                  <div class="share_goods_sale_prime"><del>￥{{goods_info.prime}}</del></div>
                </div>
                <div class="share_info_container_div_right">
                  <div class="get_coupon">领券</div>
                  <div class="coupon_difference">减{{(goods_info.prime-goods_info.price)<100?(goods_info.prime-goods_info.price).toFixed(2):(goods_info.prime-goods_info.price)}}</div>
                  <div style="clear:both"></div>
                </div>
                <div style="clear:both"></div>
              </div>
              <div style="height:55px;background:#F3F3F3;color:##333333;margin-top:5px">
                <div class="share_shop_right">
                  <div>
                    <span>VIP专享</span>
                    <span>赚：{{goods_info.t5_gain_max}}元</span>
                  </div>
                  <div>
                    <span >店主专享</span>
                    <span >赚：{{goods_info.t6_gain_max}}元</span>
                  </div>
                </div>
                <div style="float:right;width:20%;line-height:55px;background:#D3D3D3;text-align:center" v-myclick="makeprofit"  v-row-active.tapmode>开通></div>
              </div>
              <div class="share-title" style="padding-top:15px;padding-bottom:30px">{{goods_info.title}}</div>
            </div>
            </div>
            <div class="goods_info_bottom">
                <div class="goods_info_bottom_left" v-myclick="[goods_info.goods_id, openGoodsDetail]">领券购买</div>
              <div class="goods_info_bottom_right" v-myclick="[{share:goods_info.share,goods_id:goods_info.goods_id}, share]">分享赚钱</div>
            </div>
            <!-- <div class="my-order-body" style="padding-top: 30px;" v-cloak v-if="goodsList.length==0">
                <div style="text-align:center;padding: 20px;">
                    <img v-src="'../../image/not_available.png'" width="70px" height="70px"/>
                    <div style="padding-top:10px ">
                        <span>没找到您要的商品</span>
                    </div>
                </div>

            </div> -->
        </div>
        <script src="../../script/api.js"></script>
        <script src="../../script/vue.js"></script>
        <script src="../../script/app.js"></script>
        <script src="../../script/url.js"></script>
        <script src="../../script/common.js"></script>
        <script src="../../script/components.js"></script>
        <script>
                     var goods_info;
                     var wx;
                     var clipBoard;
                     var listOf2col = true;
                     apiready = function () {
                         showProgress();
                          MNActionButton = api.require('PIActionButton');
                          clipBoard = api.require('clipBoard');
                          wx = api.require('wx');
                         param = api.pageParam;
                         setBSImg();
                         new Vue({
                             el: '#blank'
                         });
                         var data = {
                             member_id: getPrefs('member_id'),
                             goods_id: param.goods_id
                         };
                         var callback = function (ret) {
                             goods_info = ret.content;
                             if (getPrefs('token')) {
                               user = JSON.parse(getPrefs('user'));
                               member_type = user.member_type;
                             }else{
                               member_type= 5;
                             }
                             initApp();
                             api.parseTapmode();
                         };
                         pinet.post(URL.getGoodsInfo, data, callback);
                         addListeners();
                     };

                     function initApp() {
                         vm = new Vue({
                             el: "#app",
                             data: {
                                 goods_info: goods_info,
                                 BSImg: Vue.BSImg,
                                 key: 0,
                                 member_type:member_type
                             },
                             methods: {
                               share: function (infos) {
                                   if(!getPrefs('token')){
                                       reLogin();
                                   }else{
                                     share = infos.share;
                                     var sharestr = share.url;
                                     var tempstr = sharestr.split("&");
                                     for(var i=0;i<tempstr.length;i++){
                                       var iscloud = tempstr[i].indexOf("member_id=");
                                       if(iscloud>=0){
                                         var old_member_id = tempstr[i].split("=")[1];
                                         break;
                                       }
                                     }
                                     var member_id = getPrefs('member_id');
                                     if(old_member_id!==member_id){
                                       var str1 = sharestr.replace('member_id='+old_member_id, 'member_id='+member_id);
                                       share.url  = str1;
                                     }
                                     var attributes = {
                                         goods_id:infos.goods_id
                                     };
                                     var sharesuffix = {
                                       eventId:'t004_c006_a002',
                                       eventLable:'精选-商品-分享',
                                       attributes:attributes
                                     }
                                    //  onEvent('t002_c003_a001','抢购-时段-商品-购买',attributes);
                                     openMNActionButton(share,sharesuffix);
                                   }
                               },
                               copyDesc: function (text) {
                                   clipBoard.set({
                                       value: text
                                   }, function (ret) {
                                       if (ret) {
                                           api.toast({
                                               msg: '已复制到剪贴板',
                                           });
                                       }
                                   });
                               },
                               openGoodsDetail: function (goods_id) {
                                   if(!getPrefs('token')){
                                       reLogin();
                                   }else{
                                     var attributes = {
                                         goods_id:goods_id
                                     };
                                     onEvent('t004_c006_a001','精选-商品-购买',attributes);
                                     openWin('../home/browser', {goods_id: goods_id,buyshareeventId:'t004_c006_a003',category_id:'',eventLable:'精选-商品'});
                                   }
                               },
                               makeprofit:function(){
                                 if (!getPrefs('token')) {
                                     reLogin();
                                     return;
                                 }
                                 openWin('../user/makeprofit');
                               },
                             },
                         })
                     }
                     function addListeners() {
                         api.addEventListener({
                             name: 'viewappear'
                         }, function () {
                             onPageStart();
                         });

                         api.addEventListener({
                             name: 'viewdisappear'
                         }, function (ret, err) {
                             onPageEnd();
                         });

                         api.addEventListener({
                             name: 'keyback'
                         }, function (ret, err) {
                             onPageEnd();
                             api.closeWin();
                         });
                     }
        </script>
    </body>
</html>
